#在django视图函数中返回HTTP响应


from    django.http import HttpResponse
from django.shortcuts import redirect,render
def hello(request):
    return HttpResponse("HEllO")

def span(request):
    return HttpResponse("<span>这是一个段落</span><import type='text'/>")

#跳转页面
def red(request):
    return redirect("https://www.baidu.com")


##跳转页面
def test1(request):
    return render(request,"html/test1.html")

# 字典中的值可以传给前端页面
def test2(request):
    data = "Horgen"
    return render(request,"html/test2.html",{"name":data})

def test3(request):
    data = ["192.168.106.%s" %i for i in range(1,11) ]

    return render(request,"html/test3.html",{"ip":data})

def test4(request):
    data_01 = "martin"
    data_02 = ["这是：%s" %i for i in range(1,6) ]
    data_03 = {"nginx":"1.18","docker":"2.2","k8s":"2.3.3","asd":"123"}

    return render(request,"html/test4.html",{"data_01":data_01,
                                        "data_03":data_03,
                                        "data_02":data_02})

#匹配页面时必须得输入数字
def test5(request):
    return HttpResponse("显示小说内容")

#把后面输入的数字传入到视图函数中
def test6(request,n):
    return HttpResponse("显示小说ID:  %s  的内容" % n)



